package com.yenlien.traceyun.plant.utils;

import lombok.SneakyThrows;

import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;

public class ResponseUtils {

    @SneakyThrows
    public static void setResponseHeader(HttpServletResponse response, String fileName) {
        //设置响应头
       // response.setContentType("application/vnd.ms-excel");
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        String name = URLEncoder.encode(fileName, "UTF-8");
        response.setHeader("Content-disposition", "attachment;filename=" + name + ".xlsx");
    }
}
